<template>
	<!-- 首页 -->
	<view>
		<view class="search-box" @click="goSearch" >
			<mSearch class="mSearch-input-box" :mode="2" button="inside" :show="false"  >
			</mSearch>
		</view>
		<swiperlb></swiperlb>

		<context :proclassData="proclassData"></context>

		<uni-popup ref="popupLogin" type="dialog">
			<wu-popup-login @refdata="loadData1" type="success" :content="message" :before-close="true" @confirm="dialogConfirm" @close="dialogClose"></wu-popup-login>
		</uni-popup>

	</view>
</template>



<script>
	import {
		// getTest,
		getProclass
	} from '@/api/index/service.js';

	import mSearch from '@/components/mehaotian-search-revision/mehaotian-search-revision.vue';
	// import mSearch from 'sea';


	import swiperlb from '@/pages/index/Indexchild/swiperlb/swipwelb.vue'
	import context from '@/pages/index/Indexchild/context/context.vue'

	// import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import WuPopupLogin from '@/components/uni-popup/wu-popup-login.vue'
	import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
	import uniPopupShare from '@/components/uni-popup/uni-popup-share.vue'

	export default {
		data() {
			return {
				title: 'Hello',
				proclassData: [],

				message: '想要获取权限进行登录!!',
				userInfoOpenId: '',
				role:'',
			}
		},
		components: {
			mSearch,
			swiperlb,
			context,
			//对话框
			// uniPopup,
			WuPopupLogin,
			uniPopupMessage,
			uniPopupShare

		},
		onReady() {

		},
		
		mounted() {
			//通知
			
			this.userInfoOpenId = uni.getStorageSync("userInfoOpenId");
			this.Infomation = uni.getStorageSync("Infomation");
			console.log(this.Infomation);
			if (!this.userInfoOpenId) {
				console.log(this.userInfoOpenId)
				this.login();
			} else {
				console.log("mounted-checkBind")
				this.checkBind();
			}
			
		},
		created() {
			console.log("created")
			// this.denglv();
			// this.loadData1();
		},
		onShow() {
			console.log("onShow")
			this.loadData1();
		},
		onReady() {
			console.log("onReady")
		},
		methods: {
			// testin(event) {
			//       event.stopPropagation();
			//     },
			checkBind(){
				this.role = uni.getStorageSync("role");
				if(this.role!=="teacher"&&this.role!=="enterprise"&&this.role!=="student"){
					console.log("checkBind")
					//信息绑定
					uni.navigateTo({
						url: "/pages/my/company/info?key=" + 0,
						success(res) {
							console.log(res)
						},
						fail() {
							console.log(res)
						},
					})
					
				}else{
					this.login();
				}
			},

			//数据请求
			loadData1() {
				getProclass()
					.then(res => {
						this.proclassData = res.data;
						console.log(res.data);
					}).catch(res => {
						console.log(res);
					})
				console.log("proclassData");
			},
			//页面跳转
			goSearch() {
				console.log("hello");
				uni.navigateTo({
					url: '/pages/index/Indexchild/search/search'
				});
			},


			dialogConfirm(done) {
				console.log('点击确认');

				done()
			},
			dialogClose(done) {
				console.log('点击取消');
				uni.showToast({
					title: "您点击取消!!",
					duration: 2000,
					icon: "none"
				})
				done()
			},
			login() {
				// this.flag = true
				this.message = "想要获取权限进行登录!!"
				this.$refs.popupLogin.open();
				console.log("-----------Aaaaa----------")
			},
		},
	}
</script>

<style>
	.search-box {
		z-index: 2;
		width: 95%;
		background-color: rgb(242, 242, 242);
		padding: 15upx 2.5%;
		display: flex;
		justify-content: space-between;
		position: sticky;
		top: 0;
	}

	.search-box .mSearch-input-box {
		width: 100%;
	}

	.search-box .input-box {
		width: 85%;
		flex-shrink: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.search-box .search-btn {
		width: 15%;
		margin: 0 0 0 2%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-shrink: 0;
		font-size: 28upx;
		color: #fff;
		background: linear-gradient(to right, #ff9801, #ff570a);
		border-radius: 60upx;
	}

	.search-box .input-box>input {
		width: 100%;
		height: 60upx;
		font-size: 32upx;
		border: 0;
		border-radius: 60upx;
		-webkit-appearance: none;
		-moz-appearance: none;
		appearance: none;
		padding: 0 3%;
		margin: 0;
		background-color: #ffffff;
	}
</style>
